---
id: indexing
title: Indexing functions
sidebar_label: Indexing
slug: /api/indexing
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

These function are used for finding the H3 index containing coordinates, and for finding the center and boundary of H3 indexes.

## geoToH3

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Python', value: 'python'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
  ]
}>
<TabItem value="c">

```c
H3Index geoToH3(const GeoCoord *g, int res);
```

</TabItem>
<TabItem value="python">

```py
h3.geo_to_h3(lat, lng, resolution)
```

</TabItem>
<TabItem value="java">

```java
long geoToH3(double lat, double lng, int res);
String geoToH3Address(double lat, double lng, int res);
```

</TabItem>
<TabItem value="javascript">

```js
h3.geoToH3(lat, lng, res)
```

```js live
function example() {
  const lat = 45;
  const lng = 40;
  const res = 2;
  return h3.geoToH3(lat, lng, res);
}
```

</TabItem>
</Tabs>

Indexes the location at the specified resolution, returning the index of the cell containing the location.

Returns 0 on error.

## h3ToGeo

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Python', value: 'python'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
  ]
}>
<TabItem value="c">

```c
void h3ToGeo(H3Index h3, GeoCoord *g);
```

</TabItem>
<TabItem value="python">

```py
h3.h3_to_geo(h)
```

</TabItem>
<TabItem value="java">

```java
GeoCoord h3ToGeo(long h3);
GeoCoord h3ToGeo(String h3Address);
```

</TabItem>
<TabItem value="javascript">

```js
h3.h3ToGeo(h3Index)
```

```js live
function example() {
  const h = '85283473fffffff';
  return h3.h3ToGeo(h);
}
```

</TabItem>
</Tabs>

Finds the centroid of the index.

## h3ToGeoBoundary

<Tabs
  groupId="language"
  defaultValue="c"
  values={[
    {label: 'C', value: 'c'},
    {label: 'Python', value: 'python'},
    {label: 'Java', value: 'java'},
    {label: 'JavaScript (Live)', value: 'javascript'},
  ]
}>
<TabItem value="c">

```c
void h3ToGeoBoundary(H3Index h3, GeoBoundary *gp);
```

</TabItem>
<TabItem value="python">

```py
h3.h3_to_geo_boundary(h, geo_json=False)
```

</TabItem>
<TabItem value="java">

```java
List<GeoCoord> h3ToGeoBoundary(long h3);
List<GeoCoord> h3ToGeoBoundary(String h3Address);
```

</TabItem>
<TabItem value="javascript">

```js
h3.h3ToGeoBoundary(h3Index, [formatAsGeoJson])
```

```js live
function example() {
  const h = '85283473fffffff';
  return h3.h3ToGeoBoundary(h);
}
```

</TabItem>
</Tabs>

Finds the boundary of the index.
